with Interfaces; use Interfaces;
package body StrEnc is

   function UTF8_Length (S : UTF8_String) return Natural
   is
      Result : Natural := 0;
   begin
      for C of S loop
         declare
            b : Unsigned_8 := Character'Pos(C);
         begin
            if (b and 16#C0#) /= 16#80# then
               Result := Result + 1;
            end if;
         end;
      end loop;
      return Result;
   end UTF8_Length;

   function Stdout_GBK (S : Gbk_String) return String
   is
   begin
      return GBK_To_UTF8.Convert(S);
   end Stdout_GBK;

   function Stdout_BIG5 (S : BIG5_String) return String
   is
   begin
      return BIG5_To_UTF8.Convert(S);
   end Stdout_BIG5;

   function Stdout_UTF8 (S : UTF8_String) return String
   is
   begin
      return S;
   end Stdout_UTF8;

end StrEnc;
